<?php
    /**
     * Created by PhpStorm.
     * User: Administrator
     * Date: 2019/12/30
     * Time: 15:09
     */

    namespace app\index\controller;


    use app\index\lib\Jssdk;
    use think\Controller;

    class Base extends Controller
    {
        public function _initialize()
        {
            $appid = 'wxe6202dd5841827c0';
            $sercert = '182f57178d5b93c6160f9afe99510609';
            $obj = new Jssdk($appid, $sercert);
            $this->assign('appid', $appid);
            $this->assign('wx', $obj->getSignPackage());
            parent::_initialize(); // TODO: Change the autogenerated stub
        }

        /**
         * Api返回数据
         */
        final protected function apiResponse($code = 0, $msg = '', $data = array())
        {
            $response = array(
                'code' => $code,
                'msg' => $msg,
                'data' => $data
            );
            exit(json_encode($response, JSON_UNESCAPED_UNICODE));
        }
    }